home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr27 / gs26.zip / FONTS.DOC < prev    next >
Text File  |  1992-12-31  |  12KB  |  268 lines

  1.    Copyright (C) 1990, 1991 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.
  19.  
  20. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  21.  
  22. This file, fonts.doc, describes the fonts and font facilities supplied
  23. with Ghostscript.
  24.  
  25. For an overview of Ghostscript and a list of the documentation files, see
  26. README.
  27.  
  28. About Ghostscript fonts
  29. =======================
  30.  
  31. The fonts included with Ghostscript come in several parts:
  32.  
  33.     - Font data in files *.gsf: each file defines one
  34.       (transformable) font specified in outline form.
  35.  
  36.     - BuildChar procedures in gs_fonts.ps: these provide the
  37.       algorithms for interpreting the data in the .gsf files.
  38.  
  39.     - The Fontmap file: this relates Ghostscript font names to .gsf
  40.       file names.
  41.  
  42. Currently, most of the fonts supplied with Ghostscript are based on
  43. various public domain bitmap fonts, primarily the ones supplied with the
  44. X11 distribution from MIT, and on the public domain Hershey fonts.  The
  45. fonts are distributed in the file `ghostscript-N.NNfonts.tar.Z'.  The
  46. bitmap-derived fonts include the usual Helvetica, Times-Roman, and so on;
  47. see the file `Fontmap' for the complete list, in the usual roman, italic,
  48. bold, and bold italic styles (for the most part).  The Hershey fonts, on
  49. the other hand, are quite different from traditional ones; the file
  50. `hershey.doc' describes them in more detail.
  51.  
  52. There is also a single rather heavy home-grown font called Ugly.  This
  53. font is the file `uglyr.gsf' in the Ghostscript source distribution.
  54.  
  55. The file gs_fonts.ps, which is loaded as part of Ghostscript
  56. initialization, arranges to load fonts on demand using the information
  57. from Fontmap.  If you want to preload all of the known fonts, invoke the
  58. procedure
  59.     loadallfonts
  60. This is not done by default, since the fonts occupy about 50K each and there
  61. are a lot of them.
  62.  
  63. Ghostscript fonts are actually ordinary Ghostscript programs: they use the
  64. extension .gsf instead of .ps simply to be informative.  This convention
  65. is only embodied in the Fontmap file: there is no code that knows about
  66. it.
  67.  
  68. If you want to try out the fonts, prfont.ps contains code for printing a
  69. sampler.  Load this program, by including it in the gs command line or by
  70. invoking
  71.     (prfont.ps) run
  72. and then to produce a sampler of a particular font, invoke
  73.     /fontName DoFont
  74. e.g.
  75.     /Times-Roman DoFont
  76.  
  77. Contents of fonts
  78. -----------------
  79.  
  80. A Ghostscript font is a dictionary with a standard set of keys as follows.
  81. The keys marked with a * have the same meanings as in P*stScr*pt fonts;
  82. those marked with # have the same meanings as in Adobe Type 1 fonts.  Note
  83. that FontName is required; StrokeWidth is required for all stroked or
  84. outlined fonts; and Metrics is not currently supported.
  85.  
  86. *    - FontMatrix <array>: the transformation from character
  87.       coordinates to user coordinates.
  88.  
  89. *    - FontType <integer>: the type of the font, either 1 or 3.
  90.  
  91. *    - FontBBox <array>: the bounding box of the font.
  92.  
  93. *    - Encoding <array>: the map from character codes to character
  94.       names.
  95.  
  96. *    - FontName <name>: the name of the font.
  97.  
  98. *    - PaintType <integer>: an indication of how to interpret the
  99.       character description from CharInfo.
  100.  
  101. *    - StrokeWidth <number>: the stroke width for outline fonts.
  102.  
  103. *    - FontInfo <dictionary>: additional information about the font
  104.       (optional, not used by the standard Ghostscript software).
  105.  
  106. *    - UniqueID <integer>: a unique number identifying the font.
  107.  
  108. *    - BuildChar <procedure>: the procedure for showing a character
  109.       (not required in type 1 fonts).
  110.  
  111. #    - CharStrings <dictionary>: the map from character names to character
  112.       descriptions (relevant only in type 1 fonts).
  113.  
  114. #    - Private <dictionary>: additional information used by the
  115.       algorithms for rendering outlines fonts (relevant only in type 1
  116.       fonts).
  117.  
  118. The format of values in the CharStrings and Private dictionaries are
  119. described in the Adobe Type 1 Font Format book.
  120.  
  121. Adding your own fonts
  122. =====================
  123.  
  124. Ghostscript can use any Type 1 or Type 3 font that is acceptable to other
  125. PostScript language interpreters.  Ghostscript also provides a way to
  126. construct a Type 1 font from a bitmap font in BDF format, which is a
  127. popular format in the Unix world.
  128.  
  129. If you want to add fonts of your own, you must edit Fontmap to include an
  130. entry for your new font at the end.  The format for entries is documented
  131. in the Fontmap file.  Since later entries in Fontmap override earlier
  132. entries, any fonts you add will supersede the corresponding fonts supplied
  133. with Ghostscript.  Note that the font name in the Fontmap entry must be
  134. the same as the FontName in the font itself.
  135.  
  136. In the PC world, Type 1 fonts are customarily given names ending in .PFA
  137. or .PFB.  Ghostscript can use these directly; you just need to make the
  138. entry in Fontmap.  If you are going to use a commercial Type 1 font (such
  139. as fonts obtained in conjunction with Adobe Type Manager) with
  140. Ghostscript, please read carefully the license that accompanies the font;
  141. Aladdin Enterprises and the Free Software Foundation take no
  142. responsibility for any possible violations of such licenses.
  143.  
  144. If you want to convert a BDF file to a scalable outline, use the program
  145. bdftops.ps (and invoking shell script bdftops.bat or bdftops).  Run the
  146. shell command
  147.     bdftops <BDF_file_name> [<AFM_file1_name> ...] <your_gsf_file_name>
  148.       <font_name> <uniqueID> [<encoding_name>]
  149. e.g.,
  150.     bdftops pzdr.bdf ZapfDingbats.afm pzdr.gsf ZapfDingbats 4100000
  151. Then make an entry for the .gsf file in Fontmap as described above.  You
  152. may find it helpful to read, and to add an entry to, the fonts.mak file,
  153. which is a makefile for converting the standard Ghostscript fonts.
  154.  
  155. Precompiling fonts
  156. ==================
  157.  
  158. You can compile any Type 1 font into C and link it into the Ghostscript
  159. executable.  (Type 1 fonts include any font whose name ends with .pfa or
  160. .pfb, and it also includes all the Ghostscript .gsf fonts except for the
  161. Hershey fonts.)  This doesn't have any effect on rendering speed, but it
  162. eliminates the time for loading the font dynamically, which may make a big
  163. difference in total rendering time, especially for multi-page documents.
  164. (Because of RAM and compiler limitations, you should only use compiled
  165. fonts on MS-DOS systems if you are using a 32-bit compiler such as Watcom
  166. C/386 or djgpp; you will run out of memory if you use compiled fonts with
  167. the Borland compiler.)  Fonts that have been precompiled and linked in
  168. this way do not need to appear in the Fontmap, although if they do appear
  169. there, no harm is done.
  170.  
  171. The utility for precompiling fonts is called font2c.  Note that font2c is
  172. a PostScript language program, so you must have Ghostscript already
  173. running to be able to run font2c; you must also have entries in the
  174. Fontmap for the fonts you want to compile.)  For example, to precompile
  175. the Times-Italic font,
  176.     font2c Times-Italic ptmri.c
  177. where the first argument is the font name and the second is the name of
  178. the .c file.  You can use any file name you want, as long as it ends in
  179. .c.  It doesn't have to be limited to 8 characters, unless your operating
  180. system requires this.  We suggest that you use names xxxx.c, where
  181. xxxx.gsf or xxxx.pfa is the name of the font file in the Fontmap file,
  182. just so you don't have to keep track of another set of names.  (If you are
  183. running on a VMS platform, or another platform where the C compiler has a
  184. limit on the length of identifiers, you must do something slightly more
  185. complicated; see the section 'Platforms with identifier length limits'
  186. below.  Also, on VMS, you must put quotes "" around the font name so that
  187. the VMS command processor doesn't convert the name to lower case.)
  188.  
  189. Besides running font2c, you must arrange things so that the file will be
  190. compiled from C to machine code, and linked into the executable.  All
  191. environments except VMS use the same procedure for this, which we will now
  192. describe.  For VMS environments, the necessary information is contained in
  193. comments in the command files (vms-cc.mak and vms-gcc.mak); if you are
  194. using Ghostscript on VMS, ignore the rest of this subsection.
  195.  
  196. First, you must add the compiled fonts "feature" to your
  197. platform-specific makefile.  On MS-DOS systems, you edit tc.mak,
  198. bc.mak, bcwin.mak, msc.mak, or watc.mak; on Unix systems, you edit
  199. makefile.  Find the definition of FEATURE_DEVS in the makefile, e.g.,
  200.     FEATURE_DEVS=filter.dev dps.dev
  201. Add ccfonts.dev on the end, e.g.,
  202.     FEATURE_DEVS=filter.dev dps.dev ccfonts.dev
  203.  
  204. Next, you must add the specific fonts to the generic makefile.  On MS-DOS
  205. systems, you edit gs.mak; on Unix systems, you edit makefile.  Find the
  206. line in the relevant makefile that says
  207.     ccfonts_=ugly.$(OBJ)
  208. Edit this to add your compiled font file names, e.g.,
  209.     ccfonts_=ugly.$(OBJ) ptmri.$(OBJ)
  210. Just below this, you will find a line that says
  211.     ccfonts1=Ugly
  212. Add your own fonts to the end of this line, e.g.,
  213.     ccfonts1=Ugly Times_Italic
  214. Notice that you must replace `-' by `_' in the font name.  If the line
  215. gets too long, add another line of the same form, e.g.,
  216.     ccfonts1=Ugly
  217.     ccfonts2=Times_Italic
  218. Now find the lines that say
  219.     ugly.$(OBJ): ugly.c $(CCFONT)
  220.         $(CCCF) ugly.c
  221. Add a similar pair of lines for each font, separating these entries from
  222. the existing entries and from each other by a blank line.  (The makefile
  223. includes lines for a few more fonts than this already.)  In our example,
  224.     ugly.$(OBJ): ugly.c $(CCFONT)
  225.         $(CCCF) ugly.c
  226.  
  227.     ptmri.$(OBJ): ptmri.c $(CCFONT)
  228.         $(CCCF) ptmri.c
  229.  
  230. Finally, run `make'.  The executable will now include the fonts you added.
  231. They will be present in FontDirectory when Ghostscript starts up.
  232.  
  233. Note that ugly.c, ncrr.c, etc. are not supplied with the Ghostscript
  234. fileset, since they are quite large and can easily be recreated using the
  235. font2c program as described above.
  236.  
  237. Platforms with identifier length limits
  238. ---------------------------------------
  239.  
  240. On some platforms, the C compiler and/or linker have a limit on the number
  241. of significant characters in an identifier.  On such platforms, you must
  242. do a little extra work.
  243.  
  244. Let N be the maximum number of significant characters in an identifier
  245. (typically 31).  For each font whose name is longer than N-5 characters,
  246. pick an arbitrary identifier that we will call the "short name".  This can
  247. be any string you want, as long as it contains only letters, digits, and
  248. underscores; is no longer than N-5 characters; and is not the same as any
  249. other font name or short name.  A good choice for this would be to use the
  250. name of the C file.  (There is no harm in doing this for fonts with names
  251. shorter than N-5 characters, it's just not necessary.)
  252.  
  253. You must do two different things for fonts that require a short name.
  254. First, you must supply the short name as a third argument to the font2c
  255. program.  For example, to compile NewCenturySchlbk-BoldItalic using the
  256. short name "pncbi",
  257.     font2c NewCenturySchlbk-BoldItalic pncbi.c pncbi
  258. Then when you add the font to the gsaddmod line in the makefile, use the
  259. short name, not the actual font name, e.g.,
  260.     ccfonts2=pncbi
  261. instead of
  262.     ccfonts2=NewCenturySchlbk_BoldItalic
  263. Everything else is as described above.
  264.  
  265. This procedure doesn't change the name of the font in the Fontmap, or as
  266. seen from within Ghostscript; it's just a workaround for a limitation of
  267. some older compilers.
  268.